package cn.edu.ctbu.firstdp.api;

import cn.edu.ctbu.firstdp.entity.Student;
import cn.edu.ctbu.firstdp.entity.Teacher;
import cn.edu.ctbu.firstdp.service.StudentService;
import cn.edu.ctbu.firstdp.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/teacher")
public class TeacherApiController {
    @Autowired
    private TeacherService teacherService;

    @GetMapping("/list")
    public List<Teacher> findAll(){
        List<Teacher> teachers = teacherService.getALL();
        return teachers;

    }
    @GetMapping("/{id}")
    public Teacher findById(@PathVariable Integer id){
        Teacher teacher = teacherService.findById(id);
        return teacher;

    }
    @PostMapping("/add")
    public Teacher add(Teacher teacher){
        return teacherService.add(teacher);
    }
    @PutMapping("/update1")
    public Teacher update1(Teacher teacher){
        return teacherService.update1(teacher);
    }
    @DeleteMapping("/delete1/{id}")
    public void delete1(@PathVariable Integer id){
        teacherService.delete1(id);
    }
}
